package com.eight.cloud.gateway.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.socket.client.TomcatWebSocketClient;
import org.springframework.web.reactive.socket.client.WebSocketClient;
import org.springframework.web.reactive.socket.server.RequestUpgradeStrategy;
import org.springframework.web.reactive.socket.server.upgrade.TomcatRequestUpgradeStrategy;

/**
 * bean配置
 *
 * @ClassName: BeanRegistrar
 * @Author: TXC
 * @Date: 2024-10-08 22:28
 **/
@Component
public class BeanRegistrar {
    /**
     * 配置升级策略
     * @return
     */
    @Bean
    @Primary
    public RequestUpgradeStrategy requestUpgradeStrategy() {
        return new TomcatRequestUpgradeStrategy();
    }

    /**
     * 配置WebSocketClient
     * @return
     */
    @Bean
    @Primary
    public WebSocketClient webSocketClient() {
        return new TomcatWebSocketClient();
    }

}
